package com.devo.icecream.data

import androidx.annotation.IntRange
import retrofit2.http.*

interface API {

    /**
     * 获取广告
     * @param type Int 广告类型  1-开屏广告,2-制作中广告
     * @param page Int 页码
     * @param limit Int 每页大小
     * @return Any
     */
    @GET("api/app/adv")
    suspend fun fetchAdvertising(
        @IntRange(from = 1, to = 2)
        @Query("type")
        type: Int,
        @Query("page")
        page: Int,
        @Query("rows")
        limit: Int
    ): BaseResponse<List<Advertising>>

    /**
     * 客服电话
     * @return Any
     */
    @GET("api/app/service/tel")
    suspend fun fetchServiceTel(): BaseResponse<Map<String, String>>

    /**
     * 确认订单
     * @param body RequestBody
     * @return Any
     */
    @Headers("Content-Type: application/json")
    @POST("api/app/order/confirm")
    suspend fun pushOrder(@Body order: OrderDto): BaseResponse<OrderBean>

    /**
     * 取消订单
     * @param orderId String 订单ID
     * @return Any
     */
    @FormUrlEncoded
    @POST("api/app/order/cancel/{orderId}")
    suspend fun cancelOrder(
        @Path("orderId") orderId: String
    ): BaseResponse<Any>


    /**
     * 上报订单错误,并退款
     *
     * @param body RequestBody
     * @return Any
     */
    @Headers("Content-Type: application/json")
    @POST("api/app/order/failure")
    suspend fun pushOrderFailure(
        @Body failure: FailureDto
    ): BaseResponse<Any>


    /**
     * 获取商品列表
     * @param page Int
     * @param size Int
     * @return BaseResponse<List<ProductBean>>
     */
    @GET("api/app/food")
    suspend fun fetchProducts(
        @Query("page") page: Int,
        @Query("rows") size: Int,
    ): BaseResponse<List<ProductBean>>


    @GET("api/app/food/ingredient")
    suspend fun fetchIngredient(): BaseResponse<IngredientDto>;

    @Headers("Content-Type: application/json")
    @POST("api/app/order/finish")
    suspend fun checkOrder(
        @Body checkInfo: CheckOrderDtoBean
    ): BaseResponse<Any>;

    @GET("api/router/location")
    suspend fun getCellInfo(mcc: Int, mnc: Int, lac: Int, ci: Int): BaseResponse<Any>


}